package com.zmn.plat.admin.controller.orderconfig.returnvisit.content;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dictionary.GlobalDict;
import com.zmn.plat.model.entity.orderconfig.returnvisitcontent.ReturnVisitContent;
import com.zmn.plat.model.entity.orderconfig.returnvisitcontent.ReturnVisitContentQuery;
import com.zmn.plat.model.vo.orderconfig.returnvisitcontent.ReturnVisitContentVO;

/**
 * 类描述:回访内容列表控制器
 *
 * @author linfeng
 * @since 2019/10/21/14:46
 */
@Controller
@RequestMapping(value = "/orderconfig/returnvisitcontent/")
public class ReturnVisitContentListController extends ReturnVisitContentBaseController {
    private Logger logger = LoggerFactory.getLogger(ReturnVisitContentListController.class);

    @RequestMapping(value = "list")
    @RequiresPermissions("/orderconfig/returnvisitcontent/list.action")
    public ModelAndView list(@ModelAttribute ReturnVisitContentQuery query) {
        List<ReturnVisitContentVO> items = returnVisitContentBService.listPageByQuery(query);

        ModelAndView mav = new ModelAndView("orderconfig/returnvisit/content/list");
        mav.addObject("vo", query);
        mav.addObject("platTypeList", GlobalConsts.getPlatList());
        mav.addObject("items", items);

        return mav;
    }

    @RequestMapping(value = "detail")
    @RequiresPermissions("/orderconfig/returnvisitcontent/detail.action")
    public ModelAndView detail(@RequestParam(value = "id", defaultValue = "0") Integer id) {
        ReturnVisitContent returnVisitContent;
        if (id > 0) {
            returnVisitContent = returnVisitContentService.findByKey(id);
        } else {
            returnVisitContent = new ReturnVisitContent();
        }

        ModelAndView mav = new ModelAndView("orderconfig/returnvisit/content/detail");

        mav.addObject("statuses", GlobalDict.getStatusList(false));
        mav.addObject("vo", id);
        mav.addObject("returnVisitContent", returnVisitContent);
        return mav;
    }
}
